from typing import *

'''
1  1  两数之和  
two-sum
2025-05-23 11:00:23
'''

# leetcode submit region begin(Prohibit modification and deletion)
class Solution:
    def twoSum1(self, nums: List[int], target: int) -> List[int]:
        for i, val in enumerate(nums):
            for j in range(i + 1, len(nums)):
                if target - val == nums[j]:
                    return [i, j]
        return []

    def twoSum(self, nums: List[int], target: int) -> List[int]:
        map = {}
        for i, val in enumerate(nums):
            map[val] = i
        for i, val in enumerate(nums):
            if target - val in map and map[target - val] != i:
                return [i, map[target - val]]
        return []


        
# leetcode submit region end(Prohibit modification and deletion)


if __name__ == '__main__':
    solution = Solution()
    print(solution.twoSum([2, 7, 11, 15], 9))